#pragma once

//#include <srs_utest_protocol.hpp>
#include <srs_utest.hpp>
#include <srs_rtmp_utility.hpp>
#include <srs_rtmp_stack.hpp>
#include <srs_rtmp_handshake.hpp>
#include <srs_protocol_buffer.hpp>
#include <string>

#ifdef SRS_AUTO_SSL
using namespace _srs_internal;
#endif

#include <srs_rtmp_io.hpp>

class MockEmptyIO : public ISrsProtocolReaderWriter {
public:
    MockEmptyIO();
    virtual ~MockEmptyIO();
    // for protocol
public:
    virtual bool is_never_timeout(int64_t timeout_us);
    // for handshake.
public:
    virtual int read_fully(void* buf, size_t size, ssize_t* nread);
    virtual int write(void* buf, size_t size, ssize_t* nwrite);
    // for protocol
public:
    virtual void set_recv_timeout(int64_t timeout_us);
    virtual int64_t get_recv_timeout();
    virtual int64_t get_recv_bytes();
    // for protocol
public:
    virtual void set_send_timeout(int64_t timeout_us);
    virtual int64_t get_send_timeout();
    virtual int64_t get_send_bytes();
    virtual int writev(const iovec* iov, int iov_size, ssize_t* nwrite);
    // for protocol/amf0/msg-codec
public:
    virtual int read(void* buf, size_t size, ssize_t* nread);
};

class MockBufferIO : public ISrsProtocolReaderWriter {
public:
    int64_t recv_timeout;
    int64_t send_timeout;
    int64_t recv_bytes;
    int64_t send_bytes;
    // data source for socket read.
    SrsSimpleBuffer in_buffer;
    // data buffer for socket send.
    SrsSimpleBuffer out_buffer;
public:
    MockBufferIO();
    virtual ~MockBufferIO();
    // for protocol
public:
    virtual bool is_never_timeout(int64_t timeout_us);
    // for handshake.
public:
    virtual int read_fully(void* buf, size_t size, ssize_t* nread);
    virtual int write(void* buf, size_t size, ssize_t* nwrite);
    // for protocol
public:
    virtual void set_recv_timeout(int64_t timeout_us);
    virtual int64_t get_recv_timeout();
    virtual int64_t get_recv_bytes();
    // for protocol
public:
    virtual void set_send_timeout(int64_t timeout_us);
    virtual int64_t get_send_timeout();
    virtual int64_t get_send_bytes();
    virtual int writev(const iovec* iov, int iov_size, ssize_t* nwrite);
    // for protocol/amf0/msg-codec
public:
    virtual int read(void* buf, size_t size, ssize_t* nread);
};
